<!-- 物流线路 - 表单编辑页面 -->
<template>
  <div class="page-container">


    <el-form ref="formEl" :model="formValue" label-width="120px" class="common-form-panel-div">

      <ex_header_spiler :title="$tt('label_srm_product_insurance_info')"></ex_header_spiler>
      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_srm_product_insurance_name')">
            <el-input v-model="formValue.productName"></el-input>
          </el-form-item>
        </el-col>
      </el-row>


      <el-row>
        <el-col>
          <el-form-item :label="$tt('label_srm_product_insurance_quote_rate')">
            <el-input v-model="formValue.insuranceAmountRate">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="2">
          <el-form-item :label="$tt('label_srm_contract_template_remark')">
            <el-input v-model="formValue.remark"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <ex_header_spiler :title="$tt('label_srm_product_insurance_api_service')"></ex_header_spiler>

      <pms-supply-service ref="supplyServiceEl" type="INSURANCE"></pms-supply-service>

    </el-form>

    <div style="position: relative; left: 140px; margin-top: 30px; margin-bottom: 20px;">
      <el-button type="primary" @click="submitForm()">{{ $tt('label_submit') }}</el-button>
      <el-button @click="goback()">{{ $tt('label_back') }}</el-button>
    </div>

  </div>
</template>
<script>

import TransportPriceCfg from '@/component/pms/transport_price_cfg.vue'

import PmsSupplyService from '@/component/pms/pms-supply-service.vue'

import router_params from '@/mixin/router_params';
export default {
  title: "label_srm_product_insurance_supplier_service",
  components: { TransportPriceCfg, PmsSupplyService },
  mixins: [router_params],
  data() {

    return {
      edit: false,

      formValue: {
        productType: 'INSURANCE',
        supplyId: '',
        apiServiceTypeCode: '',
        apiServiceId: ''
      }

    };
  },
  mounted() {




  },
  methods: {
    init_data_default(into_params) {
      this.edit = !!into_params.edit
      if (this.edit) {
        if (into_params.id) {
          this.loading = true
          this.$ajax({
            url: "/fms-api/product/PmsSupplyProductRpc/detailProduct.json",
            method: 'post',
            data: { id: into_params.id },
            success: (res) => {
              if (res && res.data) {
                this.formValue = res.data
                this.$refs['supplyServiceEl'].updateForm({
                  'supplyId': this.formValue.supplyId,
                  'apiServiceTypeCode': this.formValue.apiServiceTypeCode,
                  'apiServiceId': this.formValue.apiServiceId
                })
              }
              this.$emit("tagModifyLabel", { _key: 'label_edit_any_code', type: this.$tt('label_srm_product_insurance_supplier_service'), code: res.data.productName })
            }
          })
        }
        this.$emit("tagModifyLabel", { _key: "label_edit_any", type: this.$tt('label_srm_product_insurance_supplier_service') })
      } else {
        this.$emit("tagModifyLabel", { _key: "label_new_any", type: this.$tt('label_srm_product_insurance_supplier_service') })
      }
    },
    handleClick() {

    },
    submitForm() {

      let _this = this

      let submitData = { ...this.formValue, ..._this.$refs['supplyServiceEl'].getFormData() }

      _this.$ajax({
        url: '/fms-api/product/PmsSupplyProductRpc/saveUpdateProduct.json',
        type: 'json',
        data: submitData,
        success: (responseData) => {

          this.$message({
            showClose: true,
            message: this.$tt('tip_submit_success'),
            type: 'success'
          })

          this.return_emit(null, "reload")
          this.$tag.tagClose(null, this.intoPath)

        },
        afterAjax() {

        }
      });

    },

    goback() {
      this.$tag.tagClose(null, this.intoPath)
    }
  }
};

</script>
<style>
.product-line-limit-div,
.product-line-limit-div-2 {
  display: flex;
}


.product-line-limit-div .product-line-limit-col {
  width: 220px;
  text-align: center;
  margin-right: 10px;
}
</style>
